#include <iostream>
#include <vector>
#include <queue>
#include <climits>
using namespace std;
int n;

int main() {

	cin>>n;
	vector<int> vecArr(n+1),dp(n+1,INT_MAX);
	for(int i=1;i<=n;++i){
		cin>>vecArr[i];
	}	
	dp[1]=0;
	for(int i=1;i<=n;++i){
		if(vecArr[i]>0 && dp[i]!=INT_MAX){
			for(int j=i+1;j<=min(i+vecArr[i],n);++j){
				dp[j]=min(dp[j],dp[i]+1);
			}
		}
	}
	if(dp[n]==INT_MAX){
		cout<<-1<<endl;
	}
	else{
		cout<<dp[n]<<endl;
	}
	
	return 0;
}
